MBUF_BLOCKDEV_RCMDR_TTY="umount \$MOUNTPOINT && echo -ne '\n\aERROR: Detected wrong sequence number!\nEnter Y to retry with another volume. ' && read tmp
&& test "$tmp" = "Y" -o "$tmp" = "y" && mount -t \$blockdev_fs_type \"\$device\" \$MOUNTPOINT"
FIND_STD_OPTS="-noleaf -depth" # to avoid endless errors on non unix fs
O "Toggle Once Only Flag [$scheduled_only_once]" \
M "Back to main menu" 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
case `cat $TMP/$DIALOGFILE` in
T) enter_time
Configuration_changed=YES
;;
B) schedule
echo "$0 --scheduled-backup $schedulename" | at $scheduletime
exit
;;
R) Restore_part_I
if [ "$restore_part_I" = "FAILED" ]
then
return
fi
schedule
pwd
read
echo "$0 --scheduled-restore $schedulename" | at $scheduletime
exit
;;
M) schedule=NO
return
;;
O) $DIALOG --title "Schedule Once Only Flag" --yesno "
If you have specified a time setting that
calls this backup more than only once, its
configuration file must not be removed, so
please choose <NO> here.
If you want this backup to be performed
only once, it can savely remove its confi-
guration file on termination, so please
choose <YES>.
Perform backup only once?
" 16 47
if [ $? = 0 ]
then
scheduled_only_once=YES
else
scheduled_only_once=NO
fi
Configuration_changed=YES
;;
esac
else
schedule=NO
return
fi
done
}
Verify() # accepts option "auto" to avoid prompt for medium
{
if [ "$Verify_src_loaded" != "YES" ]
then
. "$SRCDIR/$VERIFY_SRC"
fi
Verify_II $1
}
cleanup()
{
rm -rf $TMPFILES
rmdir $TMP 2>/dev/null
}
set_multivolume()
{
multivolume=YES
if [ "$archive_format" = "TAR" ]
then
if [ "$protect_newer" = "YES" ]
then
protect_newer=NO
Configuration_changed=YES
MsgBox \
"You have selected TAR archive format
and chosen to protect newer files during
restore. This is not possible with tar.
Disabling protection feature."
fi
if [ "$compression" != "NONE" ]
then
compression=NONE
Configuration_changed=YES
MsgBox "Switching off compression for multi-\nvolume tar-archives."
fi
if [ "$double_buffering" = "YES" ]
then
double_buffering=NO
Configuration_changed=YES
MsgBox "Switching off double buffering\nfor multivolume tar-archives."
fi
fi
}
#
# check wether combination of options is valid:
#
Check_Settings()
{
if [ "$archive_format" = "TAR" ]
then
if [ "$multivolume" = "YES" ]
then
if [ "$compression" != "NONE" ]
then
ErrorBox \
"If you want to use compressed multivolume archives,
you must use the AFIO-format, TAR is not capable of
this. Otherwise, you cannot compress or just write
archives of at most one volume's length.
Setting archive format to AFIO."
archive_format=AFIO
Configuration_changed=YES
fi
if [ "$double_buffering" = "YES" ]
then
ErrorBox \
"You cannot use double buffering with multivolume
archives in TAR-format.
As TAR does not support compression with multi-
volume archives, this should not be necessary
anyway.
Switching off double buffering."
double_buffering=NO
Configuration_changed=YES
fi
fi
fi
if [ "$double_buffering" = "YES" ]
then
if [ -z "$ddbufsize" ]
then
ErrorBox \
"You must specify a buffersize when using double
buffering.
Setting it to 4096k."
ddbufsize=4096k
Configuration_changed=YES
fi
if [ "$device_type" = "FLOPPY" ]
then
ErrorBox \
"You selected double buffering for a floppy
drive. This is not possible.
Disabling double buffering."
double_buffering=NO
Configuration_changed=YES
fi
fi
if [ "$use_patterns" = "YES" -a "$directoriesonly" = "YES" ]
then
ErrorBox \
"You are trying to use include/exclude shell
patterns together with the \"Directories-Only\"
setting. This is not possible, sorry.
Disabling \"Directories-Only\" setting."
directoriesonly=NO
Configuration_changed=YES
fi
if [ "$archive_format" = "AFIO" -a "$directoriesonly" = "YES" ]
then
ErrorBox \
"AFIO format archives cannot use the
Directories-Only-Flag.
It is switched off now."
directoriesonly=NO
Configuration_changed=YES
fi
if [ "$verify_archive" = "YES" -a "$device_type" = "BLOCKDEV" ]
then
ErrorBox \
"Verify for BLOCKDEV archives is
not implemented currently.
Switching off Verify-Setting."
Configuration_changed=YES
fi
if [ "$archive_format" = "AFIO" -a "$compression" = "PGP" -a "$HasAFIO242" != "YES" ]
then
MsgBox \
"You are using pgp-encryption with
an \"old\" afio program. This is
not safe! See the manual or upgrade
to an afio version newer than 2.4.2!
"
fi
}
############################### MENU ROUTINES ##################
Compression_Menu()
{
while :
do
$DIALOG --title " Compression menu " --menu "\n\
Please choose one of the following compression methods. Before using\n\
pgp(1) for public key encryption, you should know what you are doing!\n\n\
The current compression is $compression, Options: $compress_options\n" 19 75 7 \
N "No compression" \
G "Compress using Gzip" \
C "Compress using Compress" \
P "Compress + Encrypt using Pgp" \
O "Set Command-line Options for compression program" \
D "Set Command-line Options for decompressing" \
"<" "Return to Backup Parameters Menu" 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
case `cat $TMP/$DIALOGFILE` in
N) compression=NONE
Configuration_changed=YES
;;
G) compression=GZIP
Configuration_changed=YES
;;
C) compression=COMPRESS
Configuration_changed=YES
;;
P) compression=PGP
$DIALOG --inputbox "Please enter name of pgp key:" 8 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ] && test -n "`cat $TMP/$DIALOGFILE`"
then
pgpkey=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
;;
O) $DIALOG --inputbox "Please enter any optional command line arguments\n\
for the compression program (e.g. -1 for gzip).\n\
Default is: \"$compress_options\"\n(Enter a single space for no options.)" 13 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
if [ "`cat $TMP/$DIALOGFILE`" != "" ] ; then
compress_options=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
fi
;;
D) $DIALOG --inputbox "Please enter any optional command line arguments\n\
for the compression program when used for decompressing.\n\
Default is: \"$decompress_options\"\n(Enter a single space for no options.)" 13 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
if [ "`cat $TMP/$DIALOGFILE`" != "" ] ; then
decompress_options=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
fi
;;
"<") return
;;
esac
else
return
fi
done
}
Floppy_Format_Menu()
{
while : ; do
$DIALOG --title " Floppy Format Menu " --menu "\n\
Please choose a disk format to use:\n(current: $floppy_format)\n" 18 70 7\
"1722/1440" "1.7Mb on a 3.5 drive" \
"1440/1440" "1.44Mb on a 3.5 or 5.25 drive" \
"720/1440" "720Kb on a 3.5 drive" \
"1200/1200" "1.2Mb on a 5.25 drive" \
"720/1200" "720Kb on a 5.25 drive" \
"User defined" "Enter your own value from /etc/fdprm" \
"<" "Return to Device Menu" 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
case `cat $TMP/$DIALOGFILE` in
"<") return
;;
"User definded")
$DIALOG --inputbox \
"Please enter your own value for a floppy format description,
like specified in \"/etc/fdprm\":
" 7 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
tmp=`cat $TMP/$DIALOGFILE`
if [ "$tmp" != "" ]
then
floppy_format="$tmp"
Configuration_changed=YES
fi
fi
;;
*) floppy_format=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
;;
esac
else
return
fi
done
}
test_tape_device()
{
if [ "Autodetect_src_loaded" != "YES" ]
then
. $SRCDIR/$AUTODETECT_SRC
fi
insert_media && \
$DIALOG --title " Warning! " --yesno \
"
This test will erase any data on the tape!
Are you sure that you want to continue?" 8 50
if [ $? = 0 ]
then
test_tape_device_II "$device"
if [ $? = 0 ]
then
MsgBox "Your tape drive
\"$device\"
is compatible with KBackup."
else
MsgBox "Your tape drive
\"$device\"
is a rewind-on-close device and
therefore not compatible with
KBackup. Please choose a non-re-
winding one and try again."
fi
fi
}
autodetect_tape_device()
{
if [ "Autodetect_src_loaded" != "YES" ]
then
. $SRCDIR/$AUTODETECT_SRC
fi
autodetect_tape_device_II
autodetect_tape_menu
}
Device_Menu()
{
while : ; do
$DIALOG --title " Device Menu " --menu "\n\
Choose a device for your backup and optionally set the device related\n\
options. If you are choosing a tape drive, it must not do an automatic
rewind at the end of a file being written.
Autodetection might not work on your system, use it with care!
Current setting: $device" 24 76 11 \
A "Attempt to autodetect tape device"\
C "Check tape drive for compatibility"\
D "Set device type [$device_type]"\
"Specify" "Enter your own device/archive file"\
"/dev/fd0" "First floppy drive"\
"/dev/fd1" "Second floppy drive"\
T " Blockdev filesystem type [$blockdev_fs_type]"\
M " Blockdev make filesystem command [$blockdev_mkfs]"\
F "Set Floppy format [$floppy_format]"\
R "Set device for resetting driver [$resetdevice]"\
"<" "Return to KBackup Config Menu" 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
case `cat $TMP/$DIALOGFILE` in
A) autodetect_tape_device
;;
F) Floppy_Format_Menu
;;
D) case "$device_type" in
TAPE)
device_type=FLOPPY
;;
FLOPPY)
device_type=BLOCKDEV
;;
BLOCKDEV)
device_type=TAPE
;;
esac
Configuration_changed=YES
;;
/dev/fd0|/dev/fd1)
device_type=FLOPPY
device=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
Floppy_Format_Menu
;;
Specify) $DIALOG --inputbox "Please specify the device/file to use.\n(default: $device)" \
9 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
newdevice=`cat $TMP/$DIALOGFILE`
if [ -n "$newdevice" ]
then
device="$newdevice"
Configuration_changed=YES
fi
if [ -c "$device" ] ; then
device_type=TAPE
MsgBox "You specified a character device,\nassuming it is a tape streamer."
else
if [ -L "$device" ] ; then
device_type=TAPE
MsgBox "You specified a symbolic link,\nassuming it is a tape streamer."
else
if [ -b "$device" ] ; then
device_type=FLOPPY
MsgBox "You specified a block device,\nassuming it is a floppy drive."
fi
fi
fi
fi
;;
R) $DIALOG --inputbox "Please specify the device for resetting the driver:\n(default: $resetdevice)\nThis seems to work only with the QIC02-driver!\n" \
11 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ] && test -n "`cat $TMP/$DIALOGFILE`"
then
if [ -c `cat $TMP/$DIALOGFILE` ] ; then
resetdevice=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
else
$DIALOG --msgbox "\nNo character device!\nKeeping old value." 5 40
fi
fi
;;
"<") return
;;
T) $DIALOG --title " Filesystem type for mountable block devices " \
--inputbox \
"Please specify the filesystem type to use on the block
device. KBackup will automatically format and error check
every backup medium.
Recommended: \"minix\" on floppies, \"ext2\" for removable
hard drives.
" 14 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
tmp=`cat $TMP/$DIALOGFILE`
if [ "$tmp" != "" ]
then
blockdev_fs_type="$tmp"
Configuration_changed=YES
fi
fi
;;
M) $DIALOG --title " Formatting command for mountable block devices " \
--inputbox \
"Please specify the command to execute for formatting a block device.
KBackup will automatically create a filesystem on every medium and
afterwards mount it, using the current filesystem setting. Of course,
the formatting command must match the setting for the filesystem type.
Current filesystem type setting: \"$blockdev_fs_type\"
The string \$device will be changed into the actual device name.
Suggested values:
mkfs -t minix \$device nblocks : to create a minix fs
mkfs -t ext2 \$device : to create an ext2 fs
fdformat \$device && mkfs -t minix \$device
: to low-level format a floppy and put a minix fs on it
(Just press ENTER to keep the current value.)" 23 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
tmp=`cat $TMP/$DIALOGFILE`
if [ "$tmp" != "" ]
then
blockdev_mkfs="$tmp"
Configuration_changed=YES
fi
fi
;;
C) # check tape drive for compatibility
test_tape_device
;;
esac
else
return
fi
done
}
Multivolume_Menu()
{
while : ; do
$DIALOG --title " Multivolume Archives Menu " --menu "
Options relevant for handling archives that span more than one
physical volume.
The MultiBuf program is able to automatically detect the end of a
backup medium and will prompt you to change it. It also adds se-
quence information to the archive, preventing you from using the
backup media in the wrong order when restoring.
Normally, you do not need to change these settings." 23 72 7\
S "Set MultiBuf blocksize [$multibuf_blksize]"\
N "Set number of MultiBuf blocks per call [$multibuf_nblocks]"\
I "Use sequence information in MultiBuf [$multibuf_seq_info]"\
E "Set command to execute at end of tape"\
B "Set command to execute at begin of new tape"\
T "Toggle use of MultiBuf [$use_multibuf]"\
"<" "Return to Parameters Menu" 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
case `cat $TMP/$DIALOGFILE` in
I) if [ $multibuf_seq_info = YES ]
then
multibuf_seq_info=NO
else
multibuf_seq_info=YES
fi
Configuration_changed=YES
;;
T) if [ "$use_multibuf" = "YES" ]
then
use_multibuf=NO
else
use_multibuf=YES
fi
Configuration_changed=YES
;;
S) $DIALOG --inputbox \
"Please give the size of a single block in bytes.
This should be a small kilobyte value, like e.g. 4096.
(default: $multibuf_blksize)\n" \
11 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
multibuf_blksize=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
;;
N) $DIALOG --inputbox \
"Please give the number of blocks for buffering. Multiplied with the
blocksize this should give a reasonable big buffer. The bigger it is
the less overhead it causes. The smaller it is, the more effective
will MultiBuf use your volumes. For tapes I would recommend something
a total buffer size of 100K (blocksize=1024, number of blocks=100).
In general, the total buffer size must(!) be smaller than the size
of your volume.
(default: $multibuf_nblocks)\n"\
16 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
multibuf_nblocks=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
;;
"<") return
;;
E) $DIALOG --inputbox \
"The command specified here is used by MultiBuf to either prompt
the user to change tapes or to tell an automatic loading mechanism
to change tapes. However, this command will be executed whenever
MultiBuf detects an end of tape.
If you want to use the default value, enter DEFAULT .
If you want to keep the current value, just press enter.
The current value is:
\"$multibuf_cmd1\"\n" 17 74 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
tmp=`$SED "1,$ s/"/\\"/g" <$TMP/$DIALOGFILE`
if [ "$tmp" != "" ]
then
multibuf_cmd1="$tmp"
Configuration_changed=YES
fi
fi
;;
B) $DIALOG --inputbox \
"The command specified here is called by MultiBuf after the
tape has been changed. Usually, after changing tapes, you
should execute something like a \"mt rewind\".
Even if your tape is auto-rewinding any new cartridge, you
should issue the rewind command. (QIC-02 causes problems
otherwise.)
To use this default value, enter DEFAULT .
If you want to keep the current value, just press enter.
The current value is:
\"$multibuf_cmd2\"\n" 20 74 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
tmp=`$SED "1,$ s/"/\\"/g" <$TMP/$DIALOGFILE`
if [ "$tmp" != "" ]
then
multibuf_cmd2="$tmp"
Configuration_changed=YES
fi
fi
;;
esac
else
return
fi
done
}
Advanced_Options_Menu()
{
while : ; do
$DIALOG --title " Advanced Options Menu " --menu "\n\
The options in this menu deeply affect the operation of KBackup. You\n\
should know what you are doing before making any changes. If you are\n\
not sure, go back to the main menu and read the manual first.\n" 20 77 8 \
S "Backup only files specified [$specifiedfilesonly]"\
N " Edit list of files to include in backup" \
I " Initialise list of files to include" \
X "Set Find-Expert Mode [$findxpertmode]"\
O "Set find-options for Find-Expert Mode"\
E "Set option to manually edit list of files [$manualedit]"\
D "Toggle Directories-Only Flag [$directoriesonly]" \
"<" "Return to File Selection Menu" 2>$TMP/$DIALOGFILE
T) $DIALOG --inputbox "Please enter the KBackup directory (default: ~/$KBACKDIRDEFAULT)" \
9 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ] && test -n "`cat $TMP/$DIALOGFILE`"
then
datadir=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
;;
M) $DIALOG --inputbox "Please enter the directory for temporary files:" \
9 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ] && test -n "`cat $TMP/$DIALOGFILE`"
then
tmp=`cat $TMP/$DIALOGFILE`
if [ -d "$tmp" -a -w "$tmp" ]
then
changeTMP "$tmp"
Configuration_changed=YES
else
ErrorBox "Cannot access \"$tmp\" as a directory."
fi
fi
;;
D) Device_Menu
;;
O) $DIALOG --title " Online Menu Command " --inputbox "
Please specify the command for viewing the Online Manual.
Examples are:
less $docdir/manual.asc
dialog --textbox $docdir/manual.asc 24 77
lynx $docdir/whtml/KBackup.html
netscape $docdir/html/KBackup.html
Current setting: $manual_command" 15 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
if [ "`cat $TMP/$DIALOGFILE`" != "" ]
then
manual_command=`cat $TMP/$DIALOGFILE`
Configuration_changed=YES
fi
fi
;;
"W") if [ "$device_type" != "TAPE" ]
then
ErrorBox "This option does only make sense
when using a tape drive."
else
if [ "$AutoRewind" = "YES" ]
then
AutoRewind=NO
else
AutoRewind=YES
MsgBox "You have activated the Auto-Rewind
option.
Please do not use this if you want
to write multiple archives on one
tape."
fi
Configuration_changed=YES
fi
;;
"<") return
;;
esac
else
return
fi
done
}
Write_Config()
{
Check_Settings
$DIALOG --inputbox "Please specify a unique name for this configuration:\nThe current name is:\n\"$configname\"\nJust press RETURN to keep this name." \
13 75 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
oldconfig="$configname"
configname=`cat $TMP/$DIALOGFILE`
if [ "$configname" = "" ]
then
configname="$oldconfig"
fi
if [ -d $datadir/$configname ]
then
$DIALOG --yesno \
"A configuration named\n$configname\ndoes already exist!\n\nOverwrite it with new settings?" 9 40
if [ $? = 0 ]
then
save_config
Configuration_changed=NO
else
MsgBox "Write Configuration aborted."
fi
else
save_config
Configuration_changed=NO
fi
fi
}
Configuration_Menu()
{
while : ; do
$DIALOG --title " Configuration Menu " --menu "\n\
Choose \"Configure KBackup\" for options that determine how KBackup
works; choose \"Set file selection parameters\" for deciding which
files to include in the backup.
\nThe current configuration is \"$configname\".\n\
The current parent directory is \"$parent\"." 21 77 7 \
P "Set parent directory for backup/restore " \
F "Set file selection parameters" \
C "Configure KBackup" \
W "Write a configuration file" \
L "Load a configuration file" \
D "Delete a configuration file"\
"<" "Return to main menu" 2>$TMP/$DIALOGFILE
if [ $? = 0 ]
then
case `cat $TMP/$DIALOGFILE` in
F) File_Selection_Menu
;;
C) Config_KBackup_Menu
;;
P) choose_dir $parent
parent="$choose_dir_result"
Configuration_changed=YES
;;
W) Write_Config
;;
L) find "$datadir"/* -type d -prune -printf "%f %Tx\n" |\